<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>新增仓库</title>
    <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">

    <!--标准mui.css-->
    <link rel="stylesheet" href="__PUBLIC__/css/mui.min.css">
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/css/icons-extra.css" />
    <!--App自定义的css-->
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/css/app.css" />
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/css/icon.css" />
    <style>
        .w36 {width: 50% !important;}
        .upBtn{opacity: 1;position: relative;top:-80px}
        .img-div{
            border: 1px solid #ddd;
            float: left;
            line-height: 1;
            margin-left: 5px;
            overflow: hidden;
        }
    </style>
    <script type="text/javascript" src="__PUBLIC__/js/jquery-3.2.1.min.js"></script>
    <script src="__PUBLIC__/layer_mobile/layer.js"></script>
    <script type="text/javascript" src="http://api.map.baidu.com/api?v=1.3"></script>
</head>

<body>
<header class="mui-bar mui-bar-nav">
    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
    <h1 class="mui-title">新增仓库</h1>
</header>
<div class="mui-content">
    <div  class="mui-control-content mui-active">
        <form onsubmit="return submits()" enctype="multipart/form-data" action="{:U('add_cangku')}" method="post" class="mui-input-group">
            <div class="mui-input-row h50 pr">
                <i class="mui-icon-cang mui-jm   mui-pull-left"></i>
                <label class="pl40">联系人</label>
                <input name="Contact" style="width: 50%; text-align: right" required  type="text" maxlength="10" class="mt5 mui-input mui-yuuye" placeholder="请输入联系人">
                <!--<a class="mui-navigate-right"></a>-->
            </div>
            <div class="mui-input-row h50 pr">
                <i class="mui-icon-cang kf-jm mui-pull-left"></i>
                <label class="pl40">联系电话</label>
                <input name="Mobile" style="width: 50%; text-align: right" required type="text" pattern="[0-9]*" maxlength="11" class="mt5 mui-input mui-yuuye" placeholder="请输入联系电话">
                <!--<a class="mui-navigate-right"></a>-->
            </div>
            <div class="mui-input-row h50 pr">
                <i class="mui-jszl-icon mui-city-icon  mui-pull-left"></i>
                <label class="pl40">选择城市</label>
                <!--<input style="width: 50%"  onfocus="this.blur();" id="choseCity" type="text" class="mt5 mui-input mui-yuuye" placeholder="请选择">-->
                <!--<input id="value1" type="hidden" value="20,234,504"/>-->
                <div style="width: 4rem;float: left;margin-left: 2rem">
                    <select name="ProvID" id="city1" style="width: 100%;text-align: center;padding: 0;border: none" class="mui-btn mui-btn-block mt5">
                        <option value="0">选择省</option>
                        <foreach name="data.ReturnData" item="vo">
                            <option value="{$vo.ProvID}">{$vo.Prov}</option>
                        </foreach>
                    </select>
                </div>
                <div style="width:4rem;float: left;">
                    <select name="CityID" id="city2" style="width: 100%;text-align: center;padding: 0;border: none" class="mui-btn mui-btn-block mt5">
                        <option value="item-1">选择市</option>
                    </select>
                </div>
                <div style="width: 4rem;float: left;">
                    <select name="DistrictID" id="city3" style="width: 100%;text-align: center;padding: 0;border: none" class="mui-btn mui-btn-block mt5">
                        <option value="item-1">选择区</option>
                    </select>
                </div>
            </div>
            <div class="mui-input-row h50 pr">
                <i class="mui-icon-cang mui-wz   mui-pull-left"></i>
                <label class="pl40">位置</label>
                <input id="Addr" name="Addr" style="width: 50%; text-align: right" required type="text" class="mt5 mui-input mui-yuuye" placeholder="请输入位置">
            </div>
            <div class="mui-input-row h50 pr">
                <i class="mui-icon-cang mui-cangchutype   mui-pull-left"></i>
                <label class="pl40">仓储类别</label>
                <select name="WHType" id="cclb" style="width: 60%" class="mui-btn mui-btn-block w36 mt5">
                    <option value="0">请选择仓储类别</option>
                    <foreach name="type" item="vo">
                        <option value="{$vo.id}">{$vo.name}</option>
                    </foreach>
                </select>
                <a class="mui-navigate-right"></a>
            </div>
            <div class="mui-input-row h50 pr">
                <i class="mui-icon-cang mui-jg   mui-pull-left"></i>
                <label class="pl40">仓库名字</label>
                <input name="Name" style="width: 50%; text-align: right" required  type="text" class="mt5 mui-input mui-yuuye" placeholder="请输入仓库名字">
            </div>
            <div class="mui-input-row h50 pr">
                <i class="mui-icon-cang mui-jg   mui-pull-left"></i>
                <label class="pl40">价格</label>
                <input name="PriceCust" style="width: 50%; text-align: right" required type="text" class="mt5 mui-input mui-yuuye" placeholder="请输入仓库租赁价格">
            </div>
            <div class="mui-input-row h50 pr">
                <i class="mui-icon-cang my-jm   mui-pull-left"></i>
                <label class="pl40">面积</label>
                <input name="Length" style="width:33%; text-align: right;float: left;margin-left: 2.2rem" maxlength="10"  type="text" class="mt5 mui-input mui-yuuye" placeholder="请输入租用长">
                <input name="Width" style="width: 33%; text-align: right;float: left" maxlength="10"  type="text" class="mt5 mui-input mui-yuuye" placeholder="请输入租用宽">
            </div>
            <div class="mui-input-row h50 pr">
                <i class="mui-icon-cang mui-ckjg   mui-pull-left"></i>
                <label class="pl40">建筑物结构</label>
                <select name="BuildStruct" id="jzwjg" style="width: 50%" class="mui-btn mui-btn-block w36 mt5">
                    <option value="0">请选择仓储结构</option>
                    <foreach name="type1" item="vo">
                        <option value="{$vo.id}">{$vo.name}</option>
                    </foreach>
                </select>
                <a class="mui-navigate-right"></a>
            </div>
            <div class="mui-input-row h50 pr">
                <i class="mui-icon-cang mui-ckcont   mui-pull-left"></i>
                <label class="pl40">仓库描述</label>
                <input name="Desc" style="width: 50%; text-align: right" required type="text" class="mt5 mui-input mui-yuuye" placeholder="请输入仓库描述">
            </div>
            <div class="mui-input-row  pr " style="height: auto;">
                <div class="mui-img">
                    <i class="mui-icon-cang mui-ckimg   mui-pull-left"></i>
                    <label class="pl40 mt5">仓库图片</label>
                    <span class="imgspan" >(添加图片最多9张)</span>
                </div>

                <div class="img-box" id="imgboxid"></div>
                <div style="position: relative;width: 110px;height: 110px;float: left" >
                    <input style="position: absolute;width: 110px;height: 110px;opacity: 0;top:0;left: 0" type="file"  multiple="multiple"  name="upfile" onchange="xmTanUploadImg(this)"/>
                    <img style="width: 110px;height: 110px;" src="__PUBLIC__/images/iconfont-tianjia.png"/>
                </div>

                <!--<div class="mui-img-list">-->
                <!--<img src="../../images/iconfont-tianjia.png">-->
                <!--</div>-->
                <!--<ul class="upload-ul clearfix">-->
                <!--<li class="upload-pick">-->
                <!--<div class="webuploader-container clearfix" id="goodsUpload"></div>-->
                <!--</li>-->
                <!--</ul>-->
            </div>
            <div class="mui-input-row  pr " style="height: auto;">
                <div class="mui-img">
                    <i class="mui-icon-cang mui-xkzimg mui-pull-left"></i>
                    <label class="pl40 mt5">房产证/企业许可证</label>
                </div>

                <div class="img-box" id="imgboxidf"></div>
                <div style="position: relative;width: 110px;height: 110px;float: left" >
                    <input style="position: absolute;width: 110px;height: 110px;opacity: 0;top:0;left: 0" type="file" id="fcz" multiple="multiple"  name="fcz" onchange="xmTanUploadImgf(this)"/>
                    <img style="width: 110px;height: 110px;" src="__PUBLIC__/images/iconfont-tianjia.png"/>
                </div>
                <!--<ul class="upload-ul clearfix">-->
                <!--<li class="upload-pick">-->
                <!--<div class="webuploader-container clearfix" id="goodsUploadTwo"></div>-->
                <!--</li>-->
                <!--</ul>-->
            </div>
            <div class="mui-input-row  pr " style="height: auto;">
                <div class="mui-img">
                    <i class="mui-icon-cang mui-ckpmimg mui-pull-left"></i>
                    <label class="pl40 mt5">仓库平台图</label>
                </div>
                <div class="img-box" id="imgboxidc"></div>
                <div style="position: relative;width: 110px;height: 110px;float: left" >
                    <input style="position: absolute;width: 110px;height: 110px;opacity: 0;top:0;left: 0" type="file"  multiple="multiple"  name="fileAttach[]" onchange="xmTanUploadImgc(this)"/>
                    <img style="width: 110px;height: 110px;" src="__PUBLIC__/images/iconfont-tianjia.png"/>
                </div>
               <input type="hidden" name="jingdu" id="jingdu" value=""/>
                <input type="hidden" name="weidu" id="weidu" value=""/>
            </div>

    </div>
    <!--<button type="button" class="mb20 mui-btn-sz ">保存</button>-->
    <input type="submit" class="mb20 mui-btn-sz " value="保存"/>
    </form>
</div>
</body>
<script src="__PUBLIC__/js/mui.min.js"></script>
<!--<script src="../../js/webuploader.min.js"></script>    &lt;!&ndash;上传图片的插件&ndash;&gt;-->
<!--<script src="../../js/diyUpload.js"></script>          &lt;!&ndash;上传图片的插件&ndash;&gt;-->
<script>
    //		$(function(){
    //选择图片，马上预览
    function xmTanUploadImg(obj) {

        var fl=obj.files.length;
        for(var i=0;i<fl;i++){
            var file=obj.files[i];
            var fd = new FormData();
            fd.append("upload", 1);
            fd.append("upfile", file);
            $.ajax({
                url: "{:U('ajaxImg')}",
                type: "POST",
                async : false,
                processData: false,
                contentType: false,
                data: fd,
                success: function(d) {
                    if(d.code != 200)
                    {
                        alert(code.msg)
                    }
                    else
                    {
                        url = d.url
                    }
                }
            });
            var reader = new FileReader();
            //读取文件过程方法
            reader.onloadstart = function (e) {
                console.log("开始读取....");
            }
            reader.onprogress = function (e) {
                console.log("正在读取中....");
            }
            reader.onabort = function (e) {
                console.log("中断读取....");
            }
            reader.onerror = function (e) {
                console.log("读取异常....");
            }
            reader.onload = function (e) {
                console.log("成功读取....");
                var imgstr='<img url="'+url+'"  style="width:110px;height:110px;margin-left: 2px" src="'+e.target.result+'"/>';
                var oimgbox=document.getElementById("imgboxid");
                var ndiv=document.createElement("div");

                ndiv.innerHTML=imgstr;
                ndiv.className="img-div";
                oimgbox.appendChild(ndiv);

            }

            reader.readAsDataURL(file);
        }

    }
    function xmTanUploadImgf(obj) {

        var fl=obj.files.length;
        for(var i=0;i<fl;i++){
            var file=obj.files[i];
            var reader = new FileReader();
            var fd = new FormData();
            fd.append("upload", 2);
            fd.append("upfile", file);
            $.ajax({
                url: "{:U('ajaxImg')}",
                type: "POST",
                async : false,
                processData: false,
                contentType: false,
                data: fd,
                success: function(d) {
                    if(d.code != 200)
                    {
                        alert(code.msg)
                    }
                    else
                    {
                        url = d.url
                    }
                }
            });
            //读取文件过程方法

            reader.onloadstart = function (e) {
                console.log("开始读取....");
            }
            reader.onprogress = function (e) {
                console.log("正在读取中....");
            }
            reader.onabort = function (e) {
                console.log("中断读取....");
            }
            reader.onerror = function (e) {
                console.log("读取异常....");
            }
            reader.onload = function (e) {
                console.log("成功读取....");

                var imgstr='<img style="width:110px;height:110px;margin-left: 2px" src="'+e.target.result+'"/>';
                var oimgbox=document.getElementById("imgboxidf");
                var ndiv=document.createElement("div");

                ndiv.innerHTML=imgstr;
                ndiv.className="img-div";
                oimgbox.appendChild(ndiv);

            }

            reader.readAsDataURL(file);
            //alert(1);
        }

    }
    function xmTanUploadImgc(obj) {

        var fl=obj.files.length;
        for(var i=0;i<fl;i++){
            var file=obj.files[i];
            var reader = new FileReader();

            //读取文件过程方法

            reader.onloadstart = function (e) {
                console.log("开始读取....");
            }
            reader.onprogress = function (e) {
                console.log("正在读取中....");
            }
            reader.onabort = function (e) {
                console.log("中断读取....");
            }
            reader.onerror = function (e) {
                console.log("读取异常....");
            }
            reader.onload = function (e) {
                console.log("成功读取....");

                var imgstr='<img style="width:110px;height:110px;margin-left: 2px;" src="'+e.target.result+'"/>';
                var oimgbox=document.getElementById("imgboxidc");
                var ndiv=document.createElement("div");

                ndiv.innerHTML=imgstr;
                ndiv.className="img-div";
                oimgbox.appendChild(ndiv);

            }

            reader.readAsDataURL(file);
            //alert(1);
        }

    }
    //城市选择
    $('#city1').change(function()
        {
           var id = $(this).val()
           if(id == 0)
           {
               str='<option value="0">选择市</option>';
               $('#city2').html(str)
               return false
           }
           $.post("{:U('get_city')}",{id:id},function (rel) {
               str='<option value="0">选择市</option>';
               $.each(rel, function(key, val) {
                   str+='<option value="'+val.CityID+'">'+val.City+'</option>';
               });
               $('#city2').html(str)
           })
        }
    )
    //城市选择
    $('#city2').change(function()
        {
            var cid = $('#city1').val()
            var id = $(this).val()
            if(id == 0)
            {
                str='<option value="0">选择区</option>';
                $('#city3').html(str)
                return false
            }
            $.post("{:U('get_city1')}",{cid:cid,id:id},function (rel) {
                str='<option value="0">选择区</option>';
                $.each(rel, function(key, val) {
                    str+='<option value="'+val.ID+'">'+val.Name+'</option>';
                });
                $('#city3').html(str)
            })
        }
    )
    //表单提交
    function submits() {
        var city1 = $('#city1').val()
        var city2 = $('#city2').val()
        var city3 = $('#city3').val()
        var cclb = $('#cclb').val()
        var jzwjg = $('#jzwjg').val()
        var fcz = $('#fcz').val().length
        if(city1 == '0' || city2=='0' || city3=='0')
        {
            //信息框
            layer.open({
                content: '请选择城市'
                ,btn: '我知道了'
            });
            return false
        }
        if(cclb == 0)
        {
            //信息框
            layer.open({
                content: '请选择仓储类别'
                ,btn: '我知道了'
            });
            return false
        }
        if(jzwjg == 0)
        {
            //信息框
            layer.open({
                content: '请选择建筑物结构'
                ,btn: '我知道了'
            });
            return false
        }
        if(fcz < 1)
        {
            //信息框
            layer.open({
                content: '请选择房产证'
                ,btn: '我知道了'
            });
            return false
        }

    }
</script>
</html>
<body>
<div style="width:730px;margin:auto;display: none">
    要查询的地址：<input id="text_" type="text" value="宁波天一广场" style="margin-right:100px;"/>
    查询结果(经纬度)：<input id="result_" type="text" />
    <input type="button" value="查询" onclick="searchByStationName();"/>
    <div id="container"
         style="position: absolute;
                margin-top:30px;
                width: 730px;
                height: 590px;
                top: 50;
                border: 1px solid gray;
                overflow:hidden;">
    </div>
</div>
</body>
<script>
    $('#Addr').blur(function () {
        var val = $(this).val()
        searchByStationName(val)
    })
</script>
<script type="text/javascript">
    var map = new BMap.Map("container");
    map.centerAndZoom("北京市", 12);//这里是初始地图所显示的城市
    map.enableScrollWheelZoom();    //启用滚轮放大缩小，默认禁用
    map.enableContinuousZoom();    //启用地图惯性拖拽，默认禁用

    map.addControl(new BMap.NavigationControl());  //添加默认缩放平移控件
    map.addControl(new BMap.OverviewMapControl()); //添加默认缩略地图控件
    map.addControl(new BMap.OverviewMapControl({ isOpen: true, anchor: BMAP_ANCHOR_BOTTOM_RIGHT }));   //右下角，打开

    var localSearch = new BMap.LocalSearch(map);
    localSearch.enableAutoViewport(); //允许自动调节窗体大小
    function searchByStationName(val) {
        map.clearOverlays();//清空原来的标注
        //var keyword = document.getElementById("text_").value;
        var keyword = val;
        localSearch.setSearchCompleteCallback(function (searchResult) {
            var poi = searchResult.getPoi(0);
            //document.getElementById("result_").value = poi.point.lng + "," + poi.point.lat;//这里是追加到对应的input文本框里，可以根据自己的需要来修改
            if(typeof(poi)=="undefined"){
                //信息框
                layer.open({
                    content: '未获取到经纬度，请检查地址是否填写错误'
                    ,btn: '我知道了'
                });
                return false
            }

            map.centerAndZoom(poi.point, 13);
            var marker = new BMap.Marker(new BMap.Point(poi.point.lng, poi.point.lat));  // 创建标注，为要查询的地方对应的经纬度
            map.addOverlay(marker);
            //var content = document.getElementById("text_").value + "<br/><br/>经度：" + poi.point.lng + "<br/>纬度：" + poi.point.lat;
            //alert(poi.point.lng)

            $('#jingdu').val(poi.point.lng)
            $('#weidu').val(poi.point.lat)
  /*          var infoWindow = new BMap.InfoWindow("<p style='font-size:14px;'>" + content + "</p>");
            marker.addEventListener("click", function () { this.openInfoWindow(infoWindow); });*/
            // marker.setAnimation(BMAP_ANIMATION_BOUNCE); //跳动的动画
        });
        localSearch.search(keyword);
    }
</script>
</html>